export default {
  // 不用
  get01: function (params) {
    var southWest = new AMap.LngLat(116.356449, 39.859008);
    var northEast = new AMap.LngLat(116.417901, 39.893797);

    var bounds = new AMap.Bounds(southWest, northEast);
    var rectangle = new AMap.Rectangle({
      bounds: bounds,
      strokeColor: 'red',
      strokeWeight: 6,
      strokeOpacity: 0.5,
      strokeDasharray: [30, 10],
      // strokeStyle还支持 solid
      strokeStyle: 'dashed',
      fillColor: 'blue',
      fillOpacity: 0.5,
      cursor: 'pointer',
      zIndex: 50,
    });
    return rectangle;
  },

  // 获取标点
  getMarker: function (pointList) {
    const resultArray = pointList.map(item => {
      var marker = new AMap.Marker({
        position: new AMap.LngLat(item.lng + 0.0008, item.lat + 0.0006),
        icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
        anchor: 'bottom-center',
        offset: new AMap.Pixel(0, 0),
      });

      // 设置label标签
      // label默认蓝框白底左上角显示，样式className为：amap-marker-label
      marker.setLabel({
        direction: 'right',
        offset: new AMap.Pixel(5, 0), //设置文本标注偏移量
        content: "<div class='info1'>" + item.name + '，' + item.address + '</div>', //设置文本标注内容
      });

      return marker;
    });
    return resultArray;
  },

  // 获取网格
  getRectangle: function (pointList) {
    const resultArray = pointList.map(item => {
      var southWest = new AMap.LngLat(item.long, item.lat);
      var northEast = new AMap.LngLat(item.long + 0.01, item.lat + 0.005);

      var bounds = new AMap.Bounds(southWest, northEast);

      var rectangle = new AMap.Rectangle({
        bounds: bounds,
        strokeColor: 'blue',
        strokeWeight: 1,
        strokeOpacity: 0.5,
        strokeDasharray: [2, 2],
        // strokeStyle还支持 solid，dashed
        strokeStyle: 'solid，dashed',
        fillColor: 'blue',
        fillOpacity: 0.5,
        cursor: 'pointer',
        zIndex: 50,
      });
      return rectangle;
    });
    return resultArray;
  },
};
